var cmap = function(array, callback, thisObject){
	if(array.cmap){
		return array.cmap(callback, thisObject);
	}else{
		var res = [];
		for (var i = 0, len = array.length; i < len; i++) { res.push(callback.call(thisObject, array[i], i, array)); }
		return res;
	}
};

var ColorGrads = function(options){
	this.SetOptions(options);
	this.StartColor = this.options.StartColor;
	this.EndColor = this.options.EndColor;
	this.Step = Math.abs(this.options.Step);
};
ColorGrads.prototype = {
  //设置默认属性
  SetOptions: function(options) {
    this.options = {//默认值
		StartColor:	"#fff",//开始颜色
		EndColor:	"#000",//结束颜色
		Step:		20//渐变级数
    };
    ArrayCopy(this.options, options || {});
  },
  //获取渐变颜色集合
  Create: function() {
	var colors = [],
		startColor = this.GetColor(this.StartColor),
		endColor = this.GetColor(this.EndColor),
		stepR = (endColor[0] - startColor[0]) / this.Step,
		stepG = (endColor[1] - startColor[1]) / this.Step,
		stepB = (endColor[2] - startColor[2]) / this.Step;
	//生成颜色集合
	for(var i = 0, n = this.Step, r = startColor[0], g = startColor[1], b = startColor[2]; i < n; i++){
		colors.push([r, g, b]); r += stepR; g += stepG; b += stepB;
	}
	colors.push(endColor);
	//修正颜色值
	return cmap(colors, function(x){ return cmap(x, function(x){
		return Math.min(Math.max(0, Math.floor(x)), 255);
	});});
  },
  //获取颜色数据
  GetColor: function(color) {
	if(/^#[0-9a-f]{6}$/i.test(color))
	{//#rrggbb
		return cmap([color.substr(1, 2), color.substr(3, 2), color.substr(5, 2)],
			function(x){ return parseInt(x, 16); }
		)
	}
	else if(/^#[0-9a-f]{3}$/i.test(color))
	{//#rgb
		return cmap([color.substr(1, 1), color.substr(2, 1), color.substr(3, 1)],
			function(x){ return parseInt(x + x, 16); }
		)
	}
	else if(/^rgb(.*)$/i.test(color))
	{//rgb(n,n,n) or rgb(n%,n%,n%)
		return cmap(color.match(/\d+(\.\d+)?\%?/g),
			function(x){ return parseInt(x.indexOf("%") > 0 ? parseFloat(x, 10) * 2.55 : x, 10); }
		)
	}
	else
	{//color
		var mapping = {"red":"#FF0000"};//略
		color = mapping[color.toLowerCase()];
		if(color){
			return cmap([color.substr(1, 2), color.substr(3, 2), color.substr(5, 2)],
				function(x){ return parseInt(x, 16); }
			)
		}
	}
  }
};

var ct2;
var sRefresh =  function(script,flagObj,speed){
	ct2 = new StatusRefresh(script,flagObj,speed);
	ct2.Refresh();
}

var StatusRefresh = function(script,flagObj,speed){
	this._timer = null;//定时器
	this._script = script;
	this._speed = speed;
	this._flagObj = flagObj;
}

StatusRefresh.prototype = {
  //刷新
  Refresh: function() {
	this.Stop(); eval(this._script);
	if($(this._flagObj) && $(this._flagObj).value=='1'){
		this._timer = setTimeout(Bind(this, this.Refresh), this._speed);
	}
  },
  //停止
  Stop: function() {
	clearTimeout(this._timer);
  }
}

//表格行背景色切换
var TrBgTrans = function(obj){
	this._obj = obj;
	this._timer = null;//定时器
	this._index = 0;//索引
	this._colors = [];//颜色集合
	this._grads = new ColorGrads();

	this.Speed = 20;
	this.CssColor = "backgroundColor";

	this._startColor = "#FFFFFF";
	this._endColor = "rgb(219,233,251)";
	this._step = 20;

	this.Reset();
};
TrBgTrans.prototype = {
  //重设颜色集合
  Reset: function(color) {
	//修改颜色后必须重新获取颜色集合
	color = { StartColor: this._startColor, EndColor: this._endColor, Step: this._step };
	//设置属性
	this._grads.StartColor = color.StartColor;
	this._grads.EndColor = color.EndColor;
	this._grads.Step = color.Step;
	//获取颜色集合
	this._colors = this._grads.Create();
	this._index = 0;
  },
  //颜色渐入
  FadeIn: function() {
	this.Stop(); this._index++; this.SetColor();
	if(this._index < this._colors.length - 1){
		this._timer = setTimeout(Bind(this, this.FadeIn), this.Speed);
	}
  },
  //颜色渐出
  FadeOut: function() {
	this.Stop(); this._index--; this.SetColor();
	if(this._index > 0){
		this._timer = setTimeout(Bind(this, this.FadeOut), this.Speed);
	}
  },
  //颜色设置
  SetColor: function() {
	var color = this._colors[Math.min(Math.max(0, this._index), this._colors.length - 1)];
	$(this._obj).style[this.CssColor] = "rgb(" + color[0] + "," + color[1] + "," + color[2] + ")";
  },
  //停止
  Stop: function() {
	clearTimeout(this._timer);
  }
};

//简单的表格行背景色切换
var TrBgTransSimple = function(obj){
	this._obj = obj;
	this.CssColor = "backgroundColor";
	this._startColor = "#ffffff";
	this._endColor = "#dbe9fb";
	this._selColor="#c9defa";
}
TrBgTransSimple.prototype = {
 //进入颜色
  trFadeInColor: function() {
  	if($(this._obj).style[this.CssColor]==this._startColor)
  		$(this._obj).style[this.CssColor] = this._endColor;
  },
  //退出颜色
  trFadeOutColor: function(){
  	if($(this._obj).style[this.CssColor]==this._endColor)
 	 	$(this._obj).style[this.CssColor] = this._startColor;
  },
  //点击
  trOnClick:function(){
  	if($(this._obj).offsetParent.summary){//上次选择对象存在,即非首次选择
 		if($(this._obj).style[this.CssColor]==this._selColor){//已选中,取消,设置为鼠标进入的颜色
 			$(this._obj).style[this.CssColor]=this._endColor;
 		}else{												//未选中,设置为选中的颜色
			$(this._obj).style[this.CssColor]=this._selColor;
		}
  		if($(this._obj).offsetParent.summary==this._obj.id){//同一行上选择
  		
  		}else{//设置原选中行的颜色为白色
  			$($(this._obj).offsetParent.summary).style[this.CssColor]=this._startColor;
  		}
  	
  	}else{//首次选择,直接设置
  		$(this._obj).style[this.CssColor]=this._selColor;
  	}
  	//更新当前行ID的寄存器
   	$(this._obj).offsetParent.summary=this._obj.id;
  }
}


//绑定行事件
var trBind=function(tid){
	forEach($(tid).getElementsByTagName('tr'),function(x){
		var ct2 = new TrBgTransSimple(x);
		x.style.backgroundColor="#FFFFFF";
		x.onmouseover = function(){ ct2.trFadeInColor(); }
		x.onmouseout = function(){ ct2.trFadeOutColor(); }
		x.onclick = function(){ ct2.trOnClick(); }
	});
};

//绑定cell事件
var tdBind=function(tid){
	forEach($(tid).getElementsByTagName('td'),function(x){
		div=x.getElementsByTagName('div');
		if(div.length>0){
			div[0].style.border='1px solid white';
			div[0].onmouseover = function(){ this.style.border='1px solid rgb(101, 147, 207)'; };
			div[0].onmouseout = function(){ this.style.border='1px solid white'; };
		}
	});
};

//鼠标移动上时出现边框以及背景改变
var tdmo = function(x){
		$(x).style.backgroundColor="#FFFFFF";
		$(x).style.backgroundColor='#dbe9fb'; 
		$(x).style.borderColor='#6593cf';
		$(x).onmouseout = function(){ 
				if(this.style.backgroundColor=='#dbe9fb'){
					this.style.borderColor='white';  
					this.style.backgroundColor='white';
				}
			};
};

//默认出现边框,鼠标移动上背景改变,点击选中效果
var tdms = function(x){
		$(x).style.border='1px ridge #6593cf';
		$(x).onmouseover = function(){this.style.backgroundColor='#dbe9fb';};
		$(x).onmouseout = function(){
			if(this.style.backgroundColor=='#dbe9fb')
				this.style.backgroundColor='white';
			};
};


//清理表达式绑定容器的边框和事件
var expClear=function(x){
	if($(x).style.width){return;}//如果有宽度,说明是顶级表达式容器,不执行清理
	//查找直接父亲(className='stc'
	mdParent=$(x).offsetParent;
	for(var i=0;i<50;i+=1){
		if(mdParent.className=='stc') break;
		mdParent=mdParent.offsetParent;
	}
	forEach($(mdParent).getElementsByTagName('div'),function(x){
	if(x.style.borderColor){
		if(x.style.borderColor=='#6593cf'){
			x.style.border="";
			x.onclick=null;
			x.onmouseover=null;
		}
	}
	}
	);
}


//绑定行和cell
var tb=function(x){
 trBind(x);
 tdBind(x);
}

var mc = "defaut";

//绑定滑动菜单
var mb=function(x){
	forEach($(x).getElementsByTagName('div'),function(x){
		if(x.className=='sleekm'){
			x.style.width='100%';
			x.onmouseover = function(){this.style.border='1px solid rgb(101, 147, 207)';};
			x.onmouseout = function(){ this.style.border='0';this.style.borderBottom='1px solid rgb(101,147,207)';};
		}
		if(x.className=='sleeks'){
			x.style.border='1px solid white';
			x.style.width='100%';
			x.onmouseover = function(){
				this.style.border='1px solid #D4D4D4';
				this.style.background='#FEFEB4';
				};
			x.onmouseout = function(){
			//判定改菜单项是否被选择，如果是，则不修改
			if(x.id==mc) return;
				this.style.border='1px solid white';
				this.style.background='white';};
		}

	});
};
//滑动菜单单击后改变背景色
var moc=function(x){
	if(x.className=='sleeks'){
			x.style.border='1px solid white';
			x.style.width='100%';
			x.style.border='1px solid #D4D4D4';
			x.style.background='#FEFEB4';

			if(x.id != mc){
			  if($(mc)){
				$(mc).style.border='1px solid white';
				$(mc).style.background='white';
			  }
			  mc = x.id;
			}
	}
};
//数据源录入，选择数据库类型后，输入框只读设置
var setDbsInput = function(x){
	if(x.id.split(",").length>1){
		setDbsInputReadOnly(x.id.split(",")[1]);
	}
};
var setDbsInputReadOnly = function(x){
	if(x=="1" || x=="5" ){
			//设置数据库实例为可写，数据库名称为只读
			$('dssid').readOnly=false;
			$('main_db').readOnly=true;
			$('main_db').value="";
		}else{
			//设置数据库实例为只读，数据库名称为可写
			$('dssid').readOnly=true;
			$('main_db').readOnly=false;
			$('dssid').value="";
		}
};
//数据源管理提交前表单检查
var dbsSubmitcheck=function(){
    if(!checkEmpty("dsname")){
    	alert("请输入数据源名称");
    	return false;
    }else if(!checkEmpty("dsdesc")){
    	alert("请输入数据源描述信息");
    	return false;
    }else if(!checkEmpty("h,db_type_idvalue")){
    	alert("请输入数据库类型");
    	return false;
    }else if(!checkEmpty("h,typevalue")){
     	alert("请输入业务对象类型");
     	return false;
    }else if(!checkEmpty("ip")){
    	alert("请输入主机名/IP");
    	return false;
    }else if(!checkEmpty("port")){
    	alert("请输入端口");
    	return false;
    }else if(!checkEmpty("username")){
  	alert("请输入用户名");
    	return false;
    }else if(!checkEmpty("password")){
    	alert("请输入口令");
    	return false;
    }else{
    	if($("h,db_type_idvalue").value=="1" || $("h,db_type_idvalue").value=="5"){
    		if(!checkEmpty("dssid")){
		    	alert("请输入数据库实例名");
		    	return false;
		    }
    	}else{
    		if(!checkEmpty("main_db")){
		    	alert("请输入数据库名");
		    	return false;
		    }
    	}
    }
   return true;
};
//数据探查规则管理—数据范围规则管理—最大值和最小值输入框检查
var dataRangeRuleCheck=function(){
	if(!checkEmpty("MIN_VALUE") && !checkEmpty("MAX_VALUE")){
		alert("最小值和最大值至少输入一项!");
		return false;
	}
	return true;
}
//检查空true 非空 false 空
var checkEmpty=function(str){
	if($(str)){
		if($(str).value==null || $(str).value==""){
			return false;
		}
		return true;
	}else{
		return false;
	}
};

//数据提交前表单检查 x:需要检查的字段及提示信息(表单名称1,为空的提示信息1&表单名称2,为空的提示信息2....)
var submitcheck=function(x){
	var fields = x.split("&");
	for(var i=0;i<fields.length;i++){
		if(!checkEmpty(fields[i].split("^")[0])){
			alert(fields[i].split("^")[1]);
			return false
		}
	}
	return true;
};

//数据提交前表单检查 
//参数：cId:被提交的包含所有参数的容器ID
//     x:需要检查的字段及提示信息(表单名称1^为空的提示信息1^检查类型1&表单名称2^为空的提示信息2^检查类型2...)
var checkArray;
var inputCheck = function(cId,x){
	var fields = x.split("&");//分割多个字段的检查参数
	for(var i=0;i<fields.length;i++){
		checkArray = fields[i].split("^");//分割单个字段的检查参数
		if(checkArray[2]=='1'){//检查类型为空值检查
			if(!checkEmpty(checkArray[0])){//如果空值检查不通过返回提示信息
				Alert("WARRING",checkArray[1]);
				return false
			}
		}
	}
	return true;
}


/********************************************************************************************
	Event Function
********************************************************************************************/
//获取鼠标位置
var mousePosition;
var getMousePos=function(){
	if(event){
		eval("mousePosition={x:event.clientX,y:event.clientY};");
	}else{
		mousePosition={x:mouseX,y:mouseY};
	}
   return mousePosition; 
};
//获取页面对象是否有滚动条
//获取是否有纵向滚动条
var isVerticalScroll=function(x){
	if(x.scrollWidth>x.clientWidth+1)return true;//如果内容宽度大于占位宽度则有滚动条
	return false;
}
//获取是否有横向滚动条
var isHorizontalScroll=function(x){
	if(x.scrollHeight>x.clientHeight)return true;//如果内容的内容高度大于占位高度则有滚动条
	return false;
}
/**设置隐藏表达
	cId:选择项的页面ID(选择框.name+","+项ID)
	itemId:选择项的ID(一般是主键ID),
	name:checkbox的name*/
var setInputHidden = function(cId,o,mytext){
	var flag = "#";
	if($(mytext).value===""){
    		$(mytext).value = o;
    }else{
    	var values=$(mytext).value.split(flag);
    	var newValue=""; 
    	for(var i=0;i<values.length;i+=1){//遍历现有选择项，获取排除当前选择项值列表
    		if(o!=values[i]){
    			newValue = newValue + values[i]+flag;
    		}
    	}
    	if($(cId+'s').value==1){//如果选择项当前状态==未选中,提交值==newValue
    		$(mytext).value = newValue.substring(0,newValue.lastIndexOf(flag));//去掉最后的分隔符
    	}else{//如果选择项当前状态==未选中,提交值==newValue+当前选择项的ID
    		$(mytext).value=newValue+o;
    	}
    }
};
/**复选框点击文本的事件*/
var cbkt = function(cId,name){
	if($(cId+'s').value==1){
		$(cId+'i').src=$(cId+'2').value;
		$(cId+'s').value=2;
	}else{
		$(cId+'i').src=$(cId+'1').value;
		$(cId+'s').value=1;
	}	
	if(cId.split(",").length>1){	
		setInputHidden(cId,cId.substr(cId.indexOf(",")+1,cId.length),name+"value");
	}
};

/**radio处理函数 
   divid:radio图片id,
   cId:radio代表的对象的id,
   name:radio的name*/
var rad = function(divid,cId,name){
	name = "h,"+name;
	/**前缀标识: divid.substring(divid.length-1,divid.length)
	   选择的id: divid.substring(0,divid.length-1)+"s"
	   未选择id: divid.substring(0,divid.length-1)+"u"
	*/
	//创建当前radio组的当前选中节点的隐藏表单，这样可以解决同一页面下的多个radio组的情况
	if(!$(name+"current")){
		$(divid).innerHTML=$(divid).innerHTML+
	              "<input type=\'hidden\' name=\'"+name+"current\' value='-1'>"+
	              "<input type=\'hidden\' name=\'"+name+"value\' value=''>"; 
	}
	if(divid!=$(name+"current").value.substring(0,$(name+"current").value.length-1)){
		if($($(name+"current").value+"rs")){
			$($(name+"current").value+"rs").style.visibility = "Hidden";
			$($(name+"current").value+"ru").style.visibility = "inherit";
		}
		$(divid.substring(0,divid.length-2)+"rs").style.visibility = "inherit";
		$(divid.substring(0,divid.length-2)+"ru").style.visibility = "Hidden";
		if(cId.split(",").length>1){
			$(name+"value").value=cId.split(",")[1];
		}
		
	}
	$(name+"current").value = divid.substring(0,divid.length-2);
};
var radt = function(cId,name){
	if($(cId+",rs").style.visibility == "hidden"){
		rad(cId+",ru",cId,name);
	}else{
		rad(cId+",rs",cId,name);
	}
};
/**选择selectOption操作*/
var showOp = function(Sname,oId){
	$("h,"+Sname+"value").value=oId.split(",")[1];
	$("selectpop").style.visibility="hidden";
	$(Sname+"n").innerHTML=$(oId).innerHTML;
};
/**select显示可选项*/
var showItem = function(Sname,oId,evt){
	if($("selectpop").style.display!='block'){
		$("selectpop").style.visibility = "inherit";
		$("selectpop").style.left=getAbsPoint($(oId)).x+5;
		$("selectpop").style.top=getAbsPoint($(oId)).y+$(Sname+"n").clientHeight+7;
		$("selectpop").innerHTML = $(Sname+"o").innerHTML;
		$("selectpop").style.display='block';
		$("selectpop").style.width=$(Sname+"width").value;
		$("selectpop").style.height=$(Sname+"height").value;
		var e=(evt)?evt:window.event;
		if (window.event) {
			e.cancelBubble=true;
		} else {
			e.stopPropagation();
		}
		document.body.onclick=function(){hiddenSelectOption();};
	}else {
		$("selectpop").style.display='none';
	}
};
var hiddenSelectOption = function(){
	$("selectpop").style.visibility = "hidden";
	$("selectpop").style.display = "none";
	document.body.onclick = function(){};	
};
/**多选框图片切换*/
var cgp = function(oId,path){
	$(oId).style.backgroundImage ="url('"+path+"sps.gif')";
	$(oId).style.cursor="hand";
	if(!$(oId).onmouseout){
		$(oId).onmouseout = function(){
			$(oId).style.backgroundImage ="url('"+path+"sp.gif')";
		};
	}
};

/**anchor blue/red */
var ab=function(x){x.style.color ='red';
				   x.style.textDecoration='underline';
				   x.onmouseout=function(){an(this);};
				   };
var an=function(x){x.style.color ='blue';x.style.textDecoration='none';};
/**anchor default/red */
var abn=function(x,color){x.style.color ='red';
				   x.style.textDecoration='underline';
				   x.onmouseout=function(){abnn(this,color);};
				   };
var abnn=function(x,color){x.style.color=color;x.style.textDecoration='none';};
/**anchor default/color */
var abnc=function(x,defaultColor,changeColor){x.style.color = changeColor;
				   x.style.textDecoration='underline';
				   x.onmouseout=function(){abnn(this,defaultColor);};
				   };

/**little image border/noborder*/
var lib=function(x){x.style.border='1px solid #0099CC';};
var lin=function(x){x.style.border='none';};

/**small image show/unshow*/
var sis=function(x){
	$(x.id+'s').style.visibility='inherit';
	$(x.id+'u').style.visibility='hidden';
	$(x).style.borderColor='#FFD844';
	$(x).style.backgroundColor='#FFE179';
};
var siu=function(x){
	$(x.id+'s').style.visibility='hidden';
	$(x.id+'u').style.visibility='inherit';
	$(x).style.borderColor='white';
	$(x).style.backgroundColor='';
};

/**TableCellImage MouseOver*/
var tci=function(x,defaultColor){
	$(x).style.backgroundColor='#FFE179';
	$(x).style.borderColor='#FFD844';
	if($(x).onmouseout==null){
		$(x).onmouseout=function(){tcio(x,defaultColor);};
	}
};
var tcio=function(x,defaultColor){
	$(x).style.backgroundColor=defaultColor;
	$(x).style.borderColor=defaultColor;
};

/**frame close*/
var fc=function(x){
	$(x).style.visibility='hidden';
};

/**Popup**/
var p_c,p_w,p_h;
/**Alert Popup Show*/
var Alert=function(title,text){
	if((title) && (text) ){
		p_c=text.replace(/[^\x00-\xff]/g,'**').length;
		eval("p_c=Math.sqrt(p_c*14*6.5);");
		eval("p_w=p_c*2*0.58");
		p_w+=p_w%12+10;
		eval("p_h=p_c*2*0.42+44");

		popupResize("alertb");
		frameResize('alertf',Math.max(400,p_w),Math.max(300,p_h));
		$('alertft').innerText=title;
		$('alertfc').innerHTML=text;
		$("alerts").style.left=$("alertf").style.pixelWidth/2-24;
		$("alerts").style.top=$("alertf").style.pixelHeight-25;
		$("alerts").style.zIndex=$("alertf").style.zIndex+1;
		$("alert").style.visibility='inherit';
	}
};
/** 鼠标跟随 */
var mouseFollow=function(id){
		if(($(id).offsetWidth+getMousePos().x)>getWindowSize().w){
			$(id).style.left=getWindowSize().w-$(id).clientWidth;
		}else{
			$(id).style.left=getMousePos().x;
		}
		if(($(id).offsetHeight+getMousePos().y)>getWindowSize().h){
			$(id).style.top=getWindowSize().h-$(id).clientHeight;
		}else{
			$(id).style.top=getMousePos().y;
		}
}
/**将传入ID所对应的frame调整到传入的宽度,高度,并设置位置*/
var frameResize=function(id,width,height,mouseFollow){
	if(!mouseFollow){//位置居中
		$(id).style.top=document.body.clientHeight/2-height/2;
		$(id).style.left=document.body.clientWidth/2-width/2;
	}else{//鼠标跟随
		if((width+getMousePos().x)>getWindowSize().w){
			$(id).style.left=getWindowSize().w-width;
		}else{
			$(id).style.left=Math.max(getMousePos().x-width/2,0);
		}
		if((height+getMousePos().y)>getWindowSize().h){
			$(id).style.top=getWindowSize().h-height;
		}else{
			$(id).style.top=Math.max(getMousePos().y-height/2,0);
		}
	}
	$(id).style.height=height;
	$(id).style.width=width;
	if(id.substr(0,6)=='syspop'){
		$(id+'c').style.height=height-20;
		$(id+'c').style.width=width;
	}else if(id.substr(0,6)=='prompt'){
		$(id+'c').style.height=height-47;
		$(id+'c').style.width=width-40;
	}else if(id.substr(0,6)=='popview'){
		$(id+'c').style.height=height;
		$(id+'c').style.width=width;
	}
};
/**设置popup的背景DIV*/
var popupResize=function(id){
	$(id).style.top=0;
	$(id).style.left=0;
	$(id).style.height=document.body.clientHeight;
	$(id).style.width=document.body.clientWidth;
};
/** popup show+resize*/
var pp_c,pp_w,pp_h;
var popupShow=function(x){
	$(x).style.visibility='inherit';
	pp_c=$(x+"fc").getElementsByTagName("div");//正文区域内的组件对象
	if((null==pp_c) || !(pp_c[0])){return;}//如果正文区内没有div,不处理(即: 不支持文本内容)
	pp_w=Math.min(pp_c[0].clientWidth,document.body.clientWidth);
	pp_h=Math.min(pp_c[0].clientHeight+21,document.body.clientHeight);
	popupResize(x+"b");
	frameResize(x+"f",Math.max(300,pp_w),Math.max(200,pp_h));
};

/** popviewfc show+resize */
var popviewShow=function(x,mouseFollow){
	p_c=$(x+"fc").getElementsByTagName("div");//正文区域内的组件对象
	if((null==p_c) || !(p_c[0])){return;}
	//.fpd .fpc .fbv的边框宽度为8
	p_w=Math.min(p_c[0].clientWidth+8,document.body.clientWidth);
	p_h=Math.min(p_c[0].clientHeight+21,document.body.clientHeight);
	popupResize(x+"b");
	frameResize(x+"f",p_w,p_h,mouseFollow);
	$(x).style.visibility='inherit';
};

/** popmenufc show+resize */
var popmenuShow=function(x,mouseF){
	p_c=$(x+"fc").getElementsByTagName("div");//正文区域内的组件对象
	if((null==p_c) || !(p_c[0])){return;}
	//.fpd 的边框宽度为2
	p_w=Math.min(p_c[0].clientWidth+2,document.body.clientWidth);
	p_h=Math.min(p_c[0].clientHeight+2,document.body.clientHeight);
	popupResize(x+"b");
	if(mouseF){
		mouseFollow(x+"f");
		$(x+'f').style.height=p_h+2;
		$(x+'f').style.width=p_w+2;
		$(x+'fc').style.height=p_h;
		$(x+'fc').style.width=p_w;
	}else{
		frameResize(x+"f",p_w,p_h,mouseF);
	}
	$(x).style.visibility='inherit';
};

/** prompt show+resize*/
var promptShow=function(x){
	//$(x).style.visibility='inherit';
	//$(x).style.top=9999;//首次使用时,取scroll高宽时为0,必须先设置为inherit才能取到
	p_c=$(x+"fc").getElementsByTagName("div");//正文区域内的组件对象
	if((null==p_c) || !(p_c[0])){return;}
	//alert(p_c[0].id+".width="+p_c[0].style.width+"\n.clientWidth="+p_c[0].clientWidth+"\n.scrollWidth="+p_c[0].scrollWidth);
	//统计宽度
	if(p_c[0].style.pixelWidth){
		p_w=Math.min(p_c[0].style.pixelWidth+50,document.body.clientWidth);
	}else if(p_c[0].clientWidth>p_c[0].scrollWidth && p_c[0].clientWidth>0){
		p_w=Math.min(p_c[0].clientWidth+50,document.body.clientWidth);
	}else if(p_c[0].scrollWidth>0){
		p_w=Math.min(p_c[0].scrollWidth+50,document.body.clientWidth);
	}else{
		throw new Error("Prompt缺少必要的宽度数据/服务器返回异常,请检查后台日志记录.");
	}
	//alert(p_c[0].id+".height="+p_c[0].style.width+"\n.clientHeight="+p_c[0].clientWidth+"\n.scrollHeight="+p_c[0].scrollHeight);
	//统计高度
	if(p_c[0].style.pixelHeight){
		p_h=Math.min(p_c[0].style.pixelHeight+50,document.body.clientHeight);
	}else if(p_c[0].clientHeight<p_c[0].scrollHeight && p_c[0].clientHeight>0){
		p_h=Math.min(p_c[0].clientHeight+50,document.body.clientHeight);
	}else if(p_c[0].scrollHeight>0){
		p_h=Math.min(p_c[0].scrollHeight+50,document.body.clientHeight);
	}else{
		throw new Error("Prompt缺少必要的宽度数据/服务器返回异常,请检查后台日志记录.");
	}
	popupResize(x+"b");
	frameResize(x+"f",p_w,p_h,1);
	if($(x+"fbs")){
		$(x+"fbs").style.left=$(x+"f").style.pixelWidth/2-55;
		$(x+"fbs").style.top=$(x+"f").style.pixelHeight-23;
		$(x+"fbs").style.zIndex=$(x+"f").style.zIndex+1;
	}
	if($(x+"fbc")){
		$(x+"fbc").style.left=$(x+"f").style.pixelWidth/2+10;
		$(x+"fbc").style.top=$(x+"f").style.pixelHeight-23;
		$(x+"fbc").style.zIndex=$(x+"f").style.zIndex+1;
	}
	$(x).style.top=0;
	$(x).style.visibility='inherit';
};

/**浮动窗口
 * x:窗口对象
 * cId:位置容器ID
 */
var popfloatShow=function(x,cId){
	p_c=$(x+"fc").getElementsByTagName("div");//正文区域内的组件对象
	if((null==p_c) || !(p_c[0])){return;}//如果正文区内没有div,不处理(即: 不支持文本内容)
	 //统计宽度
	p_w=Math.min(p_c[0].clientWidth+2,document.body.clientWidth);
	//统计高度
	p_h=Math.min(p_c[0].clientHeight+2,document.body.clientHeight);
	
	popupResize(x+"b");
	framFloateResize(x+"f",p_w,p_h,cId);
	
	$(x).style.top=0;
	$(x).style.visibility='inherit';
};
/**将传入ID所对应的frame调整到传入的宽度,高度,并设置位置*/
var framFloateResize=function(id,width,height,cId){
    $(id).style.top=document.body.clientHeight/2-height/2;
    $(id).style.left=document.body.clientWidth/2-width/2;
	$(id).style.height=height;
	$(id).style.width=width;
	$(id+'c').style.height=height;
	$(id+'c').style.width=width;
};

/** input button 按钮效果事件 */
var bo=function(x){
	if(x.className=='bt_readonley'){
		x.onclick=null;
	}else{
		x.className='bt_mouseover';
		if(!x.onmouseout){
			x.onmouseout=function(){this.className='bt';};
		}
		if(!x.onmousedown){
			x.onmousedown=function(){this.className='bt_mousedown';};
		}
		if(!x.onmouseup){
			x.onmouseup=function(){this.className='bt_mouseup';};
		}
	}
};

/**text show 显示隐藏说明*/
var pa_width,cur_width;
var pts = function(x,parentContainer){
	ts(x.getElementsByTagName('div')[1],parentContainer,x.getElementsByTagName('div')[0]);
};
var ts=function(x,parentContainer,p_cell){
	if(!$('tip').onmouseout){
		$('tip').onmouseout=function(){textHidden($('tip'));};
	}
	if(!p_cell.onmouseout){
		p_cell.onmouseout=function(){textHidden($('tip'));};
	}
	p_c=parentContainer;
	forEach(x.getElementsByTagName('div'),
		function(x,parent,parentContainer){
			if($('tip').style.visibility=='hidden' || $('tip').style.visibility==="" ){
				if($(parentContainer)!==null){
					 $('tip').style.zIndex=$(parentContainer).style.zIndex+20;
				}
				$('tip').style.top=getMousePos().y-10;
				$('tip').style.left=getMousePos().x;
				$('tip').innerText=x.innerText;
				tsResize(p_c);
				$('tip').style.visibility='inherit';
				$('tip').onmouseover=Bind(parent,textShow,$(p_c),parent);
			}else{
				$('tip').style.visibility='hidden';
			}
		},p_cell,parentContainer);
};
/** tip隐藏 */
var textHidden=function(x){
	x.style.width=200;
	x.style.visibility='hidden';
};
var textShow=function(pc,parent){
 parent.onmouseout=null;
 tsResize(pc);
 $('tip').style.visibility="inherit";
};
/** tip大小调整 */
var contentLength;
var tsResize=function(pc){
	contentLength=getStrLength($('tip').innerText)*8;
 	cur_width=$('tip').offsetLeft+$('tip').offsetWidth;
 	if(contentLength<200 && contentLength<cur_width){
 	}
};

/** navigator*/
var navigtor_shrink=function(){
$('navigator_title').style.visibility='hidden';
$('navigator_title2').style.visibility='inherit';
$('menu').style.visibility='hidden';
$('menu').style.display='none';
$('navigator_title').style.width='25px';
$('navigator').style.width='25px';
mainResize();
};
var navigator_expand=function(){
$('navigator_title2').style.visibility='hidden';
$('navigator_title').style.visibility='inherit';
$('navigator_title').style.width='150px';
$('menu').style.visibility='inherit';
$('menu').style.display='';
$('navigator').style.width='150px';
mainResize();
};

/** banner */
var banner_hidden=0;
var bannerResize=function(){
if(banner_hidden===0){
	$('buttons').style.visibility='hidden';
	$('logo').style.visibility='hidden';
	$('logoSys').style.visibility='hidden';
	$('logoSmall').style.visibility='visible';
	$('banner').style.height=19;
	$('msgpre').style.top=0;
	$('message').style.top=0;
	banner_hidden=1;
}else{
	$('buttons').style.visibility='visible';
	$('logo').style.visibility='visible';
	$('logoSys').style.visibility='visible';
	$('logoSmall').style.visibility='hidden';
	$('banner').style.height=49;
	$('msgpre').style.top=30;
	$('message').style.top=30;
	banner_hidden=0;
}
mainResize();
};

/** main resize */
var banner_Height,navigator_Width;
var mainResize=function(){
if($('message')){$('message').style.width=Math.max(document.body.clientWidth-175,0);}
if($('banner')){
	banner_Height = $('banner').style.pixelHeight;
}else{
	banner_Height = 0;
}
if($('navigator')){
	 $('navigator').style.height=Math.max(document.body.clientHeight-banner_Height,0);
}
if($('menu')){$('menu').style.height=Math.max(document.body.clientHeight-$('banner').style.pixelHeight-27,0);}
if($('domain')){
	if($('navigator')){
		navigator_Width = $('navigator').style.pixelWidth;
	}else{
		navigator_Width = 0;
	}
	$('domain').style.height=Math.max(document.body.clientHeight-banner_Height,0);
	$('domain').style.width=Math.max(document.body.clientWidth-navigator_Width,0);
}
pbResize();
};
/** popup back resize*/
var pbResize=function(){
	if($('alert').style.visibility=="inherit"){popupResize('alertb');}
	for(var i=1;i<=7;i+=1){if($('syspop'+i).style.visibility=="inherit"){popupResize('syspop'+i+'b');}}
	if($('prompt').style.visibility=="inherit"){popupResize('promptb');}
};

/** input resize*/
var ir=function(cid,ipw,ilw,iiw){
/** 设置标签的宽度*/
forEach($(cid).getElementsByTagName('div'),function(x){
			if(x.className=='il'){x.style.width=ilw;}}
		);
/**设置Input的宽度*/		
forEach($(cid).getElementsByTagName('input'),function(x){
			if(x.className=='ii'){x.style.width=iiw;}}
		);
/**设置Input外框的宽度*/		
forEach($(cid).getElementsByTagName('div'),function(x){
			if(x.className=='ip'){x.style.width=ipw;}}
		);
};

/** 选项卡 */
var pc_parent,pc_childs,pc_child;
/** 选项卡大小调整 */
var panelResize=function(p){
	pc_parent=$(p).offsetParent;
	$(p).style.width = pc_parent.clientWidth-4;//margin-left =2 margin-right=2 所以减4
	$(p).style.height = pc_parent.clientHeight-4;//margin-top =2 margin-bottom=2 所以减4
	
	$(p+'domain').style.width = pc_parent.clientWidth-4;
	$(p+'domain').style.height = pc_parent.clientHeight-16-4;
	pc_parent.onresize=function(){panelResize(p);};
};
/** 选项卡切换显示调整 */
var panelChange=function(item){
	pc_parent = item.parentElement;
	pc_child = item.getElementsByTagName('a')[0];
	pc_childs = pc_parent.getElementsByTagName('a');
	for(var i = 0; i < pc_childs.length; i+=1){
		if(pc_childs[i]==pc_child){
			//pc_childs[i].className=='tabac'
			pc_childs[i].style.color = '#000';
			pc_childs[i].style.background = '#EEF5FD';
			pc_childs[i].style.borderBottomWidth='0px';
			pc_childs[i].style.height='20px';
			pc_childs[i].style.fontWeight='bold';
		}else{
			pc_childs[i].className=='taba'
			pc_childs[i].style.color = '#15428B';
			pc_childs[i].style.border = '1px solid #8DB2E3';
			pc_childs[i].style.background = '#DEECFD';
			pc_childs[i].style.borderBottomWidth='1px';
			pc_childs[i].style.fontWeight='normal';
			pc_childs[i].style.height='17px';
		}
	}
};
/** 设置选项卡默认选择项,如果flag为1,第一个参数为选卡ID,设置第一项为默认选择项;
    flag不是1,第一个参数为选项ID,设置指定项作为默认项;*/
var panelDefault=function(p,flag){
	if(!$(p)){return;}
	if(flag==='1'){
		pc_child = $(p).getElementsByTagName('li')[0];
		if(pc_child){
			pc_child.onclick();
		}
	}else{
		$(p).onclick();
	}
};

/** md management */
/** table resize */
var na_w,mdm_w,mdm_h,md_o_h,tem,mdParent;
/** 元数据管理区大小 */
var mdResize=function(mdManage){
	if(!$(mdManage)){return;}
	mdParent=$(mdManage).offsetParent;
	if(mdParent.id.substring(mdParent.id.length,mdParent.id.length-6)=='domain'){
		mdParent.onresize=function(){mdResize(mdManage);};
	}else{//弹出窗口内的resize
		if(p_func===null){
			p_func=function(){mdResize(mdManage);};
			return;
		}
	}
	if($(mdManage+'sl')){
		$(mdManage+'sl').style.width=$(mdManage).offsetParent.clientWidth-10;
	}
	mdTitleResize(mdManage);
	mdNaviResize(mdManage);
};
/** 元数据管理标题区大小 */
var mdTitleResize=function(mdTitle){
};
/** 改变元数据管理导航栏大小 */
var mdNaviResize=function(mdManage){
	mdParent=$(mdManage).offsetParent;
	if($(mdManage+'n')){//如果有导航栏
		if($(mdManage+'t')){//取标题行高度
			na_w=$(mdManage+'t').clientHeight;//标题高度
			tem=$(mdManage+'sl').clientHeight;//分隔线高度
		}else{
			na_w=0;
			tem=0;
		}
		$(mdManage+'n').style.height=mdParent.clientHeight-na_w-tem;
		//if(banner_shrink===1){banner_shrink=0;return;}//如果是顶部收起引起的布局,不做宽度的调整
		/**调整导航栏内树的宽度*/
		p_c=$(mdManage+'n').getElementsByTagName("div");
		for(var i=0;i<p_c.length;i+=1){
			if(p_c[i].className=='tree'){
				if(mdParent.id=='domain'){//在domain内的处理
					p_c[i].style.width=$(mdManage+'n').style.pixelWidth+2;
					p_c[i].style.height=$(mdManage+'n').style.pixelHeight-20;
				}else{
					p_c[i].style.width=$(mdManage+'n').clientWidth-20;
					p_c[i].style.height=$(mdManage+'n').style.pixelHeight-25;			
				}
				break;
			}
		}
	}
	if($(mdManage+'d')){mdDomainResize(mdManage);}//调mdDomain的布局函数
};
/** 元数据管理主信息区大小 mdDomain为绝对定位,靠上靠右*/
var mdDomainResize=function(mdManage){
	mdParent=$(mdManage).offsetParent;
	if($(mdManage+'n')){//如果有导航栏
		if($(mdManage+'nD').style.visibility=='hidden'){
			$(mdManage+'d').style.left=25;
			na_w=25;
		}else{
			na_w=$(mdManage+'n').offsetWidth;
			$(mdManage+'d').style.left=$(mdManage+'n').clientWidth;
		}
	}else{
		na_w=0;
		$(mdManage+'d').style.left=0;
	}
	if(mdParent.id!=='domain'){//在弹出窗口内的处理.因为mdDomain所以他的相对父亲是第一个绝对定位有占位的父亲:syspopf
		$(mdManage+'d').style.top=25;
		if(mdParent.style.pixelWidth>0){
			$(mdManage+'d').style.height=mdParent.style.pixelHeight;
			$(mdManage+'d').style.width=mdParent.style.pixelWidth-na_w-10;
		}
		$(mdManage).style.margin=0;
		mdParent.style.padding=0;
	}else{//在domain内的处理
		$(mdManage+'d').style.width=mdParent.clientWidth-na_w;
		$(mdManage+'d').style.height=mdParent.clientHeight;
	}
};

/********元数据管理——对象管理模板页面调整***************/
/** 元数据管理表管理界面大小 */
var mdObjectResize=function(mdDomain){
    mdParent=$(mdDomain).offsetParent;
    if(!$(mdDomain).style.width){
	    $(mdDomain).style.width=mdParent.clientWidth;
	}
    $(mdDomain).style.height=mdParent.clientHeight-5;
    if($(mdDomain+'op')){//设置操作区的宽度
    	if($(mdDomain+'t').scrollWidth-5>0){
    		$(mdDomain+'op').style.width=$(mdDomain+'t').scrollWidth;
    	}
    }
    if($(mdDomain+'t')){//设置正文区的高度
    	$(mdDomain+'t').style.height=$(mdParent).clientHeight-$(mdDomain+'op').clientHeight-5;
    	$(mdDomain+'t').style.width=$(mdParent).clientWidth-10;
    }
    mdDetailResize(mdDomain+'t',mdDomain);
};
/** 元数据管理表格字段界面大小 */
var page_c_h;
var mdDetailResize=function(mdTable,mdDomain){
	mdParent=$(mdDomain);
	if($(mdTable+'2')){
		if($('paging'+mdTable+'2')){//如果存在分页计算分页选项高度
			page_c_h=25;
		}else{
			page_c_h=0;
		}
		mdm_h=mdParent.style.pixelHeight-44-$(mdTable+'1').clientHeight-
		$(mdTable+'3').clientHeight-page_c_h;//剩余高度=父容器高度-标题栏高度(44)-概要信息界面高度-关联信息界面高度-滚动条高度(27)-表格标题高度(25)
		//alert("可用高度："+mdm_h);
		md_o_h=$(mdTable+'2').clientHeight;//实际高度
		//alert("实际高度："+md_o_h);
		if(md_o_h>mdm_h){//实际高度大于可用剩余高度
			//仅减去表1高度
			//alert("page_c_h="+page_c_h);
			mdm_h=mdParent.style.pixelHeight-44-$(mdTable+'1').clientHeight-page_c_h-3;//3为附加调整
			//alert("mdm_h="+mdm_h);
			if(mdm_h>0){
				$(mdTable+'2').style.height=Math.min(mdm_h,md_o_h);//如果实际高度小于减去表1后的剩余高度,无需调整
			}
		}else{
			//实际高度小于剩余高度,无需调整
		}
		if($(mdDomain+'op')){//设置操作区的宽度
    		$(mdDomain+'op').style.width=$(mdTable+'2').scrollWidth+17;
    	}
	}
};

/********元数据管理——操作管理模板页面调整***************/
/** 元数据操作功能区界面大小 */
var mdOperateResize=function(mdOperate){
    if(!$(mdOperate)){
    	return;
    }
    mdParent=$(mdOperate).offsetParent;
    if(!mdParent.style.pixelWidth){
    	mdParent.onresize=function(){mdOperateResize(mdOperate);};
    	return;
    }
    mdParent.onresize = null;
    p_c=$(mdOperate+'d').getElementsByTagName("div");
    if((null==p_c) || !(p_c[0])){return;}
    //alert(p_c[0].id+".clientWidth="+p_c[0].clientWidth+" .scrollWidth="+p_c[0].scrollWidth+"\nParent.width="+mdParent.style.pixelWidth);
    //alert($(mdOperate).id+".width="+$(mdOperate).style.width+"\nParnet="+mdParent.id+".width="+mdParent.style.width);
     mdDetailResize(mdOperate+'t',mdParent.id);
    $(mdOperate).style.width=mdParent.clientWidth-10;
    $(mdOperate).style.height=mdParent.clientHeight-1;
    $(mdOperate+'b').style.width=mdParent.clientWidth-10;
};

/** 分页控件跳转到按钮动作控制 */
//检查输入框是否数字,不是数字什么都不做
//检查输入框的输入数字是否超过记录集页数的最大值,如果超过设置页数为最后一页
//输入数字是否小于1页,如果小于设置页数为第一页
//参数: ncid:页数输入框控件页面ID;max:页数最大值;hpNumId:当前页数存储容器;curNumb:当前页数;后面参数:跳转执行脚本所需参数;
var pg_num;
var tbGoto= function(ncid,max,hpNumId,curNumb,
	cid,aid,rid,tid,otherCId){
	pg_num=$(ncid).value;
	if(!isNaN(pg_num)){//判断输入值是否数字
		if(pg_num<1){
		 	pg_num = 1;//输入数字是否小于1页,如果小于设置页数为第一页
		 }else{
			if(pg_num>max) pg_num = max; //检查输入框的输入数字是否超过记录集页数的最大值,如果超过设置页数为最后一页
		 }
		 if(pg_num==curNumb)return;//如果页数等于当前页数不跳转
		 $(hpNumId).value = pg_num;
		 m(cid,aid,rid,tid,otherCId);//执行数据提交脚本
	}
}

var flow_out;
/** 调整流式布局表格大小 */
var flowTabbleResize=function(tableId,overLayId){
    flow_out = $(tableId);
    if(!flow_out)return;
	if(flow_out.scrollWidth > flow_out.offsetWidth){
		flow_out.style.height = flow_out.style.pixelHeight+17;
	}
};

var ot_hig;
/** 调整数据绑定表格大小 */
var dataViewTableResize=function(tableId,outSetHeight){
	if(outSetHeight==null || outSetHeight<0)return;
	ot_hig = $(tableId).offsetHeight;
	if(ot_hig>outSetHeight){
		$(tableId).style.height = outSetHeight;
	}
};
/** 反射调用的FlowTable高度调整 */
var rflowTableResize=function(tableId,outSetHeight,rsFlag){
	ot_hig = $(tableId).offsetHeight; //获取未调整前表格高度
	if(ot_hig>outSetHeight){//如果表格内容高度大于希望表格的占位高度
		$(tableId).style.height = outSetHeight; //设置表格高度
	}
}

/** 反射调用的FlowTable宽度调整 */
var horBarWidth;
var rflowTableWidthResize=function(tableId,outSetWidth,rsFlag){
	ot_hig = $(tableId+'b').clientWidth; //获取未调整前表格宽度
	if(isVerticalScroll($(tableId))){horBarWidth=17;}else{horBarWidth=0;}
	if(ot_hig<outSetWidth){//如果表格内容宽度小于希望表格的占位宽度
		//如果有纵向滚动条,表格宽度为外面设置占位宽度减去滚动条宽度
		$(tableId+'b').style.width = outSetWidth-2-horBarWidth; //设置表格宽度,2为表格边框宽度
	}
	$(tableId).style.width = $(tableId+'b').clientWidth+horBarWidth;
}

/** 单独显示的Tree导航栏的高宽设置 */
var treeResize=function(x){//x=放置树的容器,布局将依据x的大小来
	p_c=$(x).getElementsByTagName("div");
	for(var i=0;i<p_c.length;i+=1){
		if(p_c[i].className=='tree'){
			tem=p_c[i];
			break;
		}
	}
	if($(x).onresize===null){//如果该容器没有绑定onresize事件,认为是首次调用Resize,So:绑定事件,等容器布局时会二次进入本函数
		$(x).onresize=function(){treeResize(x);};
		if($(x).clientHeight){//这里是防止容器没有resize时
			if($(x).clientHeight-20>0){
				tem.style.height=$(x).clientHeight-20;
			}else{
				tem.style.height=$(x).clientHeight;
			}
			tem.style.width=$(x).clientWidth-13;
		}
	}else{
		$(x).onresize=null;
		tem.style.height=$(x).clientHeight-20;//扣除FieldSet标题行高度
		tem.style.width=$(x).clientWidth-13;//扣除FieldSet两边留白4px+两边边框2px
	}
};

/** 规则管理三级菜单大小 */
var rulMaResize=function(mDomain){
	mdParent=$(mDomain).offsetParent.offsetParent;
	$(mDomain).style.height=mdParent.clientHeight-42-27;
	$(mDomain).style.width = $(mDomain).scrollWidth;
};

/** 获取文本的字符个数 */
var getStrLength=function(strTemp)   
{   
 var i,sum;   
 sum=0;   
 for(i=0;i<strTemp.length;i+=1){   
	if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255)){   
	 	sum=sum+1;   
	}else{  
	 	sum=sum+2;
	 } 
 }
 return sum;   
};

/** 获取当前对象在页面中的绝对位置 */
var getAbsPoint=function(e){ 
   var x = e.offsetLeft, y = e.offsetTop;
    while ((e = e.offsetParent)) { 
      x += e.offsetLeft; 
      y += e.offsetTop; 
     } 
    return { 
     x: x, 
     y: y 
	}; 
};
/** 设置对象在当前窗口中间 */
var setCenter=function(e){
	$(e).style.top=(getWindowSize().h-$(e).clientHeight)/2;
	$(e).style.left=(getWindowSize().w-$(e).clientWidth)/2;
};
/**取当前窗口的大小*/
var getWindowSize=function(){
    return {
          w:Math.max(document.body.clientWidth),
          h:Math.max(document.body.clientHeight)
    };
};

/***************流式布局表格行操作(添加,修改,删除)***********************/
/** 从表格行文本中获取行中每个单元格内容 */
var currentCellContent,regularExp,tdText,everyTdText;
var trTdArrays = function(text){
	currentCellContent=new Array();
	//Tr内容匹配表达式
	regularExp = /(?:<TD).*(?:\/TD>)/;
	//获取<tr>与</tr>之间内容
	tdText = text.match(regularExp);  
	//获取每个单元格内容
	everyTdText = tdText[0].split(/(<\/TD>)/); 
	for(var j=0;j<everyTdText.length;j++){
		currentCellContent[j] = everyTdText[j].substring
					(everyTdText[j].indexOf('>')+1,everyTdText[j].length);
	}
	return currentCellContent;
};
/* 刷新表格行 */
var refreshRow=function(tid,text){
	replaceTrObj(tid,text);
};
/** 删除表格行 */
var clickedRow,iClickCount;
var removeRow = function(movedRow){
    clickedRow = $(movedRow);
    if(!clickedRow)return;
    iClickCount = 0;
    while(clickedRow.tagName != "TR")
    {
    	if(iClickCount>30)return;
        clickedRow = clickedRow.parentNode;
        iClickCount++;
    }
    if(clickedRow.offsetParent.offsetParent.scrollHeight>clickedRow.offsetParent.offsetParent.clientHeight){
   		clickedRow.offsetParent.style.height = clickedRow.offsetParent.clientHeight-26;//当前表格高度减少一行
    }else{
   	 	clickedRow.offsetParent.offsetParent.style.height = clickedRow.offsetParent.offsetParent.clientHeight-26;//当前表格高度减少一行
    }
    clickedRow.parentNode.removeChild(clickedRow);//删除行
};
/** 修改表格行 */
var currentrowCells,curRow;
var replaceTrObj = function(curRowId,text){
	curRow = $(curRowId);
	currentrowCells = curRow.cells;//取出当前行所有列
	currentCellContent = trTdArrays(text);//获取每列的Html
	for(i=0;i<currentrowCells.length;i++) {
		currentrowCells[i].innerHTML = currentCellContent[i];//设置列Html
	}
	tb(curRowId);//设置行显示效果
};
/** 添加表格行 
  rowIndex: 插入行在表格中的位置,rowIndex小于零时插入到从表尾数起倒数第rowIndex行,未设置时插入到表尾
*/
var newRow,curTab;
function addRow(tableId,rowText,rowId,rowIndex){
	//如果指定表格容器不存在返回
	if(!$(tableId)) return;
	//获取表格
	curTab = $(tableId).getElementsByTagName('table')[0];
	if(!curTab) return;
    //在指定索引上新建表格行,如未指定索引插入行到表尾
	if(rowIndex){
		if(rowIndex<0){
			newRow = curTab.insertRow(curTab.rows.length+rowIndex);
		}else{
			newRow = curTab.insertRow(rowIndex);
		}
	}else{
		newRow = curTab.insertRow(curTab.rows.length);
	}
	//设置表格行ID
	newRow.id = rowId; 
	//添加表格列
	addTrObj(newRow,rowText); 
	//设置显示效果
	tb(rowId); 
};
var newCell;
var addTrObj = function(curRow,text){
	currentCellContent = trTdArrays(text);//获取每列的Html
	for(i=0;i<currentCellContent.length;i++) {
		newCell = curRow.insertCell()
		newCell.innerHTML = currentCellContent[i]; //设置列Html
	}
};
/** FlowTable表格修改行返回刷新提交 */
var tabId,trType,rorid,roaid;
var ter = function(rowID){
   //根据行页面ID取出行的记录ID,rid
   if(!$(rowID+'r'))throw new Error("FlowTable行刷新失败: 行主键对象不存在!");
   rorid = $(rowID+'r').value;
   //当前操作类型为修改,.trType,1
   trType = '1';
   //获取行所在表格页面ID,从表格容器中取出刷新表格动作ID
   tabId = rowIdToTabId(rowID);
   roaid = $(','+tabId+"_refAidCon").value
   //提交脚本
   trs(rowID,      //行页面ID
  	   roaid,      //获取行内容ActionID
  	   rorid,      //提交记录ID
  	   trType
  	   );
};
/** FlowTable表格添加行返回刷新提交 */
var tar = function(tabID,rid){
   //当前操作类型为添加
   trType = '2';
   //从表格容器中取出刷新表格行动作ID
   roaid = $(','+tabID+"_refAidCon").value
   trs(tabID,  //表格页面ID
  	   roaid,  //获取行内容ActionID
  	   rid,    //提交记录ID
  	   trType
  	   );
};
//从行ID中获取表格ID
var rowIdToTabId = function(rowID){
	return rowID.substr(0,rowID.indexOf('['));
};
//行刷新提交
var trs = function(cid,aid,rid,type){
    sp(cid,aid,"",0,0,'.rid,'+rid,'.rType,'+type);
};


//ExpandBlock操作脚本
var exdOnNode=function(id){
	if(!($(id+"Title").onmouseout)){
		$(id+"Title").onclick=function(){exdOnClick(id);};
		$(id+"Title").onmouseout = function(){exdOutNode(id);};
	}
	$(id+"Text").style.color='red';
	if($(id+"status").value==1){
		$(id+"Image").style.marginTop=6;
		$(id+"Image").src=$(id+"Image1u").value;
	}else{
		$(id+"Image").style.marginTop=5;
		$(id+"Image").src=$(id+"Image2u").value;
	}
};
var exdOutNode=function(id){
	$(id+"Text").style.color='#4868a9';
	if($(id+"status").value==1){
		$(id+"Image").src=$(id+"Image1s").value;
	}else{
		$(id+"Image").src=$(id+"Image2s").value;
	}
};
var exdOnClick=function(id){
	if($(id+"status").value==1){
		$(id+"status").value=2;
		$(id+"Content").style.display='block';
	}else{
		$(id+"status").value=1;
		$(id+"Content").style.display='none';
	}
	exdOnNode(id);
	exdClick(id);
};
var exdClick=function(id){
	eval($(id+"Act").value);
};



